package com.haibara.aiojquestionservice.controller;

import com.haibara.aiojmodel.model.entity.Question;
import com.haibara.aiojmodel.model.entity.QuestionSubmit;
import com.haibara.aiojquestionservice.service.QuestionService;
import com.haibara.aiojquestionservice.service.QuestionSubmitService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

@RestController
@RequestMapping("/feign")
public class QuestionFeignController {
    @Resource
    private QuestionService questionService;
    @Resource
    private QuestionSubmitService questionSubmitService;

    @GetMapping("/getQuestionById")
    public Question getQuestionById(Long questionId){
        return questionService.getById(questionId);
    }

    @PostMapping("/updateQuestion")
    public boolean updateQuestion(@RequestBody Question question){
        return questionService.updateById(question);
    }

    @GetMapping("/getQuestionSubmitById")
    public QuestionSubmit getQuestionSubmitById(Long questionSubmitId){
        return questionSubmitService.getById(questionSubmitId);
    }

    @PostMapping("/updateQuestionSubmit")
    public boolean updateQuestionSubmit(@RequestBody QuestionSubmit questionSubmit){
        return questionSubmitService.updateById(questionSubmit);
    }
}
